-- CALC_CAVE_25_TARGET_CLASS

-- 计算野猪巢穴的中心格子类型
return function()
    local dungeonId = DungeonM.getDungeonId();
    local layer = DungeonM.currentLayer();
    if dungeonId == 12 then
        if layer == 3 then
            -- 恶魔的残骸
            return 340;
        elseif layer == 9 then
            -- 生锈的重弩
            return 342;
        elseif layer == 6 or layer == 8 or layer == 10 then
            -- 试剂载体已经出现拾取了
            local rule = FeatureItemM.query(141, "rule");
            if FeatureItemM.isFeatureOpen(rule) then
                return 45;
            end

            -- 试剂配方残骸
            return 141;
        end
    elseif dungeonId == 13 then
        if DungeonM.query(400, "dbase")["formula_appear"] ~= nil then
            local formulaId = DungeonM.query(400, "dbase")["formula_appear"];
            local reagentId = ReagentM.getReagentByFormula(formulaId);

            -- 已有配方或者已经开放对应试剂，则出现一个火把的残骸
            if ItemM.getAmount(ME.user, formulaId) > 0 or
                ReagentM.isReagentActive(reagentId) then
                return 45;
            end
        end

        -- 试剂配方残骸
        return 400;
    end

    return 340;
end
